<?php
declare(strict_types=1);
namespace Field;

class AuthUserConst
{
    public const pk='';
    public const index=['NickID','UserID'];
	public const fields=['NickID','UserID','CreateAt'];
	public const comment=['NickID'=>'店铺','UserID'=>'会员ID','CreateAt'=>'绑定时间'];
	/*
    * @Field NickID
    * @Type int(11)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 店铺
    */
    public const NickID = 'NickID';
    /*
    * @Field UserID
    * @Type int(11)
    * @Collation 
    * @Null NO
    * @Key PRI
    * @Default 0
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 会员ID
    */
    public const UserID = 'UserID';
    /*
    * @Field CreateAt
    * @Type timestamp
    * @Collation 
    * @Null YES
    * @Key 
    * @Default CURRENT_TIMESTAMP
    * @Extra 
    * @Privileges select,insert,update,references
    * @Comment 绑定时间
    */
    public const CreateAt = 'CreateAt';
}

class AuthUserColumns
{
public  int $NickID;
   public  int $UserID;
   public  ?string $CreateAt='';
	public function toArray():array
	{
		return [
'NickID'=>$this->NickID,
    'UserID'=>$this->UserID,
    'CreateAt'=>$this->CreateAt,        ];
	}
}

class AuthUserRow
{
	public AuthUserColumns $data;
	public function toArray():array
	{
		return $this->data->toArray();
    }

    public function getValue(string $field):string|int|null
    {
        return match ($field){
        'NickID' => $this->data->NickID,
        'UserID' => $this->data->UserID,
        'CreateAt' => $this->data->CreateAt, default=>null
        };
    }

    public function __construct(array $data)
    {
        $this->data = new AuthUserColumns();
        isset($data['NickID']) && $this->data->NickID = (int)$data['NickID'];
           isset($data['UserID']) && $this->data->UserID = (int)$data['UserID'];
           isset($data['CreateAt']) && $this->data->CreateAt = (string)$data['CreateAt'];
    }
}
?>